<!DOCTYPE html>
<html lang="en">
<head>
	<#include "${managerViewPath}/include/macro.ftl"/>
  	<#include "${managerViewPath}/include/meta.ftl"/>  
</head>
<body>
<@ms.content>
		<@ms.contentBody>
		<@ms.nav title="编辑">
		<@ms.savebutton id="updateButton"/>
		<@ms.resetButton id="reset" value="密码重置"  onclick="reset()"  />
		</@ms.nav>
			<@ms.contentPanel>
	              <@ms.form isvalidation=true name="updateTechnician" id="updateTechnician"  action="${managerPath}/technician/update.do">
	              	<input type="hidden" name = 'id' value = "${technician.id}">
		    		<@ms.text style="width:50%;" name="name"   value = "${technician.name}" label="技师姓名" title="技师姓名" maxlength="20" placeholder="请输入技师姓名" validation={"required":"true", "data-bv-notempty-message":"技师姓名不能为空"}/>
		    		<@ms.text style="width:50%;" name="phone"   value = "${technician.phone}" label="手机号码" title="手机号码"  maxlength="11" placeholder="请输入手机号码" validation={"required":"true", "data-bv-notempty-message":"手机号码不能为空"}/>
		    		<@ms.select  name="companyId" label="所属公司"  list=JyEnterpriseList  id="enterpriseName" listKey="id"  listValue="enterpriseName" value="${technician.companyId}" style="width:33%" validation={"required":"true", "data-bv-notempty-message":"所属公司不能为空"}/>
					<@ms.select  name="sex" label="技师性别"  list=sexList  id="sex" listKey="id"  listValue="sex" value="${technician.sex}" style="width:33%" validation={"required":"true", "data-bv-notempty-message":"技师性别不能为空"}/>
		    		<@ms.text style="width:50%;" name="wxCarNumber" value="${technician.wxCarNumber}"   label="维修车车牌" title="维修车车牌"  maxlength="10" placeholder="请输入维修车车牌" validation={"required":"true", "data-bv-notempty-message":"维修车车牌不能为空"}/>
		    		
		    	</@ms.form>
			</@ms.contentPanel>	
		</@ms.contentBody>
		</@ms.content>
</body>	
<script>
$("#updateButton").click(function(){
// $("#updateTechnician")[0].submit();
$.ajax({
		url:"${managerPath}/technician/update.do",
		data:$("[name='updateTechnician']").serialize(),
		dataType:"json",
		type:"post",
		success:function(data){
		if(data.result=="true"){
			alert("保存成功！");
			location.href="${managerPath}/technician/list.do";
		}else if(data.result=="false"){
			alert(data.resultMsg);
		}else{
			alert("保持不成功！稍后再试！")
			}
		},
		error:function(){
			alert("系统异常！");
		}
	});
}
)

var  reset = function(){
if(confirm("确定重置吗？")){
	var id = $("[name='id']").val();
	$.ajax({
		url:"${managerPath}/technician/updatePWD.do",
		data:{id:id},
		dataType:"json",
		type:"post",
		success:function(data){
		if(data.result=="true"){
			alert("重置成功！");
			location.reload();
		}else{
			alert("重置不成功！稍后再试！")
			}
		},
		error:function(){
			alert("系统异常！");
		}
	});
	}
}

</script>
</html>